using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using HengTong.Model.Db.Article;


namespace HengTong.ViewModel.Article.SysArticleTagVms
{
    public partial class SysArticleTagListVm : BasePagedListVM<SysArticleTagView, SysArticleTagSearcher>
    {

        protected override IEnumerable<IGridColumn<SysArticleTagView>> InitGridHeader()
        {
            return new List<GridColumn<SysArticleTagView>>{
                this.MakeGridHeader(x => x.TagName),
                this.MakeGridHeader(x => x.TagCode),
                this.MakeGridHeader(x => x.Description),
                this.MakeGridHeader(x => x.Color),
                this.MakeGridHeader(x => x.SortOrder),
                this.MakeGridHeader(x => x.IsActive),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysArticleTagView> GetSearchQuery()
        {
            var query = DC.Set<SysArticleTag>()
                .CheckEqual(Searcher.IsActive, x=>x.IsActive)
                .Select(x => new SysArticleTagView
                {
				    ID = x.ID,
                    TagName = x.TagName,
                    TagCode = x.TagCode,
                    Description = x.Description,
                    Color = x.Color,
                    SortOrder = x.SortOrder,
                    IsActive = x.IsActive,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysArticleTagView : SysArticleTag{

    }
}
